package com.quartet.modules.alarm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quartet.modules.alarm.dao.TFatigueDrivingAlarmInfoDao;
import com.quartet.modules.alarm.entity.TFatigueDrivingAlarmInfo;
import com.quartet.modules.alarm.service.TFatigueDrivingAlarmInfoService;
import org.springframework.stereotype.Service;

/**
 * 疲劳驾驶报警信息表(TFatigueDrivingAlarmInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-05-18 09:44:33
 */
@Service("tFatigueDrivingAlarmInfoService")
public class TFatigueDrivingAlarmInfoServiceImpl extends ServiceImpl<TFatigueDrivingAlarmInfoDao, TFatigueDrivingAlarmInfo> implements TFatigueDrivingAlarmInfoService {

//    /**
//     * 服务对象
//     */
//    @Resource
//    private TVehicleInfoDao tVehicleInfoDao;
//
//    /**
//     * 服务对象
//     */
//    @Resource
//    private TVehicleOwnerInfoDao tVehicleOwnerInfoDao;
//
//    /**
//     * 服务对象
//     */
//    @Resource
//    private TDriverInfoDao tDriverInfoDao;
//
//    @Autowired
//    private TCustomerInfoDao tCustomerInfoDao;
//
//    @Autowired
//    private DictDetailServicePs dictDetailServicePs;
//    /**
//     * 功能描述: 查询疲劳驾驶报警信息
//     *
//     * @param tVehicleAlarmInfoRequestDto
//     * @return java.util.List<com.quartet.modules.alarm.dto.TFatigueDrivingAlarmInfoResponseDto>
//     * @author huipanxing huipanxing@chinasofti.com
//     * @date 2021/5/18 10:29
//     */
//    @Override
//    public List<TFatigueDrivingAlarmInfoResponseDto> selectFatigueDrivingAlarmList(TVehicleAlarmInfoRequestDto tVehicleAlarmInfoRequestDto) {
//        QueryWrapper<TFatigueDrivingAlarmInfo> queryWrapper = new QueryWrapper<>();
//        if (!ObjectUtils.isEmpty(tVehicleAlarmInfoRequestDto.getVehicleStatus())) {
//            queryWrapper.lambda().eq(TFatigueDrivingAlarmInfo::getStatus, tVehicleAlarmInfoRequestDto.getVehicleStatus());
//        }
//        List<TFatigueDrivingAlarmInfo> tFatigueDrivingAlarmInfoList = this.baseMapper.selectList(queryWrapper);
//        List<TFatigueDrivingAlarmInfoResponseDto> tFatigueDrivingAlarmInfoResponseDtoList = tFatigueDrivingAlarmInfoList.stream().map(tFatigueDrivingAlarmInfo -> {
//            TFatigueDrivingAlarmInfoResponseDto tFatigueDrivingAlarmInfoResponseDto = BeanUtil.copyProperties(tFatigueDrivingAlarmInfo, TFatigueDrivingAlarmInfoResponseDto.class);
//            QueryWrapper<TVehicleInfo> queryWrapper1 = new QueryWrapper<>();
//            queryWrapper1.lambda().eq(TVehicleInfo::getVehicleCode, tFatigueDrivingAlarmInfo.getVehicleCode());
//            TVehicleInfo tVehicleInfo = tVehicleInfoDao.selectOne(queryWrapper1);
//            if (ObjectUtils.isEmpty(tVehicleInfo)) {
//                return tFatigueDrivingAlarmInfoResponseDto;
//            }
//            tFatigueDrivingAlarmInfoResponseDto.setCarNumber(tVehicleInfo.getCarNumber());
//            tFatigueDrivingAlarmInfoResponseDto.setCarNumberColor(tVehicleInfo.getLicensePlateColor());
//            tFatigueDrivingAlarmInfoResponseDto.setEquipmentCode(tVehicleInfo.getEquipmentCode());
//            tFatigueDrivingAlarmInfoResponseDto.setFlowCardNumber(tVehicleInfo.getFlowCardNumber());
//            tFatigueDrivingAlarmInfoResponseDto.setCustomerCode(tVehicleInfo.getCustomerCode());
//
//            QueryWrapper<TVehicleOwnerInfo> queryWrapper2 = new QueryWrapper();
//            queryWrapper2.lambda().eq(TVehicleOwnerInfo::getVehicleCode, tFatigueDrivingAlarmInfo.getVehicleCode());
//            TVehicleOwnerInfo tVehicleOwnerInfo = tVehicleOwnerInfoDao.selectOne(queryWrapper2);
//            if (ObjectUtils.isEmpty(tVehicleOwnerInfo)) {
//                return tFatigueDrivingAlarmInfoResponseDto;
//            }
//            tFatigueDrivingAlarmInfoResponseDto.setOwnersName(tVehicleOwnerInfo.getOwnersName());
//            tFatigueDrivingAlarmInfoResponseDto.setOwnerPhone(tVehicleOwnerInfo.getOwnerPhone());
//
//            QueryWrapper<TDriverInfo> queryWrapper3 = new QueryWrapper();
//            queryWrapper3.lambda().eq(TDriverInfo::getVehicleCode, tFatigueDrivingAlarmInfo.getVehicleCode());
//            TDriverInfo tDriverInfo = tDriverInfoDao.selectOne(queryWrapper3);
//            if (ObjectUtils.isEmpty(tDriverInfo)) {
//                return tFatigueDrivingAlarmInfoResponseDto;
//            }
//            tFatigueDrivingAlarmInfoResponseDto.setDriverName(tDriverInfo.getDriverName());
//            tFatigueDrivingAlarmInfoResponseDto.setDriverPhone(tDriverInfo.getDriverPhone());
//
//            QueryWrapper<TCustomerInfo> queryWrapper4 = new QueryWrapper<>();
//            queryWrapper4.lambda().eq(TCustomerInfo::getCustomerCode, tFatigueDrivingAlarmInfoResponseDto.getCustomerCode());
//            TCustomerInfo tCustomerInfo = tCustomerInfoDao.selectOne(queryWrapper4);
//            if (ObjectUtils.isEmpty(tCustomerInfo)) {
//                return tFatigueDrivingAlarmInfoResponseDto;
//            }
//            tFatigueDrivingAlarmInfoResponseDto.setCustomerName(tCustomerInfo.getCustomerName());
//
//            return tFatigueDrivingAlarmInfoResponseDto;
//        }).filter(tOverSpeedAlarmInfoResponseDto -> {
//                    if (CollectionUtils.isEmpty(tVehicleAlarmInfoRequestDto.getCustomerCodeList())) {
//                        return true;
//                    } else {
//                        return tVehicleAlarmInfoRequestDto.getCustomerCodeList().contains(tOverSpeedAlarmInfoResponseDto.getCustomerCode());
//                    }
//                }
//        ).filter(tFatigueDrivingAlarmInfoResponseDto -> {
//            if (!ObjectUtils.isEmpty(tVehicleAlarmInfoRequestDto.getQueryType()) && (!ObjectUtils.isEmpty(tVehicleAlarmInfoRequestDto.getQueryValue()))) {
//                return ReflectUtil.getFieldValue(tFatigueDrivingAlarmInfoResponseDto, RandomUtils.getField(tVehicleAlarmInfoRequestDto.getQueryType())).toString().equals(tVehicleAlarmInfoRequestDto.getQueryValue());
//            } else {
//                return true;
//            }
//        }).collect(Collectors.toList());
//        return tFatigueDrivingAlarmInfoResponseDtoList;
//    }
//
//    /**
//     * 查询实时的疲劳驾驶报警列表
//     * @param tVehicleRealAlarmInfoRequestDto
//     * @return
//     */
//    @Override
//    public List<TVehicleRealAlarmInfoResponseDto> selectRealFatigueDrivingAlarmList(TVehicleRealAlarmInfoRequestDto tVehicleRealAlarmInfoRequestDto) {
//        QueryWrapper<TFatigueDrivingAlarmInfo> queryWrapper = new QueryWrapper<>();
//        if (StringUtils.isNotBlank(tVehicleRealAlarmInfoRequestDto.getAlarmLevel())) {
//            queryWrapper.lambda().eq(TFatigueDrivingAlarmInfo::getAlarmLevel, tVehicleRealAlarmInfoRequestDto.getAlarmLevel());
//        }
//        if (!CollectionUtils.isEmpty(tVehicleRealAlarmInfoRequestDto.getVehicleCodeList())) {
//            queryWrapper.lambda().in(TFatigueDrivingAlarmInfo::getVehicleCode, tVehicleRealAlarmInfoRequestDto.getVehicleCodeList());
//        }
//        if (ObjectUtils.isNotEmpty(tVehicleRealAlarmInfoRequestDto.getStartTime())) {
//            queryWrapper.lambda().gt(TFatigueDrivingAlarmInfo::getCreateTime, tVehicleRealAlarmInfoRequestDto.getStartTime());
//        }
//        if (ObjectUtils.isNotEmpty(tVehicleRealAlarmInfoRequestDto.getEndTime())) {
//            queryWrapper.lambda().lt(TFatigueDrivingAlarmInfo::getCreateTime, tVehicleRealAlarmInfoRequestDto.getEndTime());
//        }
//
//        List<TFatigueDrivingAlarmInfo> tFatigueDrivingAlarmInfoList = this.baseMapper.selectList(queryWrapper);
//        List<TVehicleRealAlarmInfoResponseDto> tVehicleRealAlarmInfoResponseDtoList = tFatigueDrivingAlarmInfoList.stream().map(tFatigueDrivingAlarmInfo -> {
//            TVehicleRealAlarmInfoResponseDto tVehicleRealAlarmInfoResponseDto = BeanUtil.copyProperties(tFatigueDrivingAlarmInfo, TVehicleRealAlarmInfoResponseDto.class);
//
//            QueryWrapper<TVehicleInfo> queryWrapper1 = new QueryWrapper<>();
//            queryWrapper1.lambda().eq(TVehicleInfo::getVehicleCode, tFatigueDrivingAlarmInfo.getVehicleCode());
//            TVehicleInfo tVehicleInfo = tVehicleInfoDao.selectOne(queryWrapper1);
//            if (ObjectUtils.isNotEmpty(tVehicleInfo)) {
//                tVehicleRealAlarmInfoResponseDto.setCarNumber(tVehicleInfo.getCarNumber());
//            }
//            QueryWrapper<TDriverInfo> queryWrapper3 = new QueryWrapper();
//            queryWrapper3.lambda().eq(TDriverInfo::getVehicleCode, tVehicleRealAlarmInfoResponseDto.getVehicleCode());
//            TDriverInfo tDriverInfo = tDriverInfoDao.selectOne(queryWrapper3);
//            if (ObjectUtils.isNotEmpty(tDriverInfo)) {
//                tVehicleRealAlarmInfoResponseDto.setDriverName(tDriverInfo.getDriverName());
//                tVehicleRealAlarmInfoResponseDto.setDriverPhone(tDriverInfo.getDriverPhone());
//            }
//            QueryWrapper<TCustomerInfo> queryWrapper4 = new QueryWrapper<>();
//            queryWrapper4.lambda().eq(TCustomerInfo::getCustomerCode, tVehicleInfo.getCustomerCode());
//            TCustomerInfo tCustomerInfo = tCustomerInfoDao.selectOne(queryWrapper4);
//            if (ObjectUtils.isNotEmpty(tCustomerInfo)) {
//                tVehicleRealAlarmInfoResponseDto.setCustomerName(tCustomerInfo.getCustomerName());
//            }
//            tVehicleRealAlarmInfoResponseDto.setAlarmType(AlarmTypeEnum.FATIGUE_DRIVING_ALARM.getValue());
//            tVehicleRealAlarmInfoResponseDto.setAlarmTypeLabel(dictDetailServicePs.getLabelByValueByCode(AlarmTypeEnum.FATIGUE_DRIVING_ALARM.getValue()));
//            return tVehicleRealAlarmInfoResponseDto;
//        }).filter(tVehicleRealAlarmInfoResponseDto -> {
//                    if (CollectionUtils.isEmpty(tVehicleRealAlarmInfoRequestDto.getCustomerCodeList())) {
//                        return true;
//                    } else {
//                        return tVehicleRealAlarmInfoRequestDto.getCustomerCodeList().contains(tVehicleRealAlarmInfoResponseDto.getCustomerCode());
//                    }
//                }
//        ).collect(Collectors.toList());
//        return tVehicleRealAlarmInfoResponseDtoList;
//    }
}